<?php
defined('IN_TS') or die('Access Denied.');
//首页

$userid = intval($TS_USER['user']['userid']);

if($userid == '0'){
	
	header("Location: index.php?app=user&ac=login");
	//$title = '同城';
	//include TmooTemplate("index");
}else{
	
	$cityid = intval($TS_USER['user']['cityid']);
	
	if($cityid == '0'){
		header("Location: index.php?app=user&ac=set&ts=city");
	}else{
		$strCity = $DB->once_fetch_assoc("select * from ".dbprefix."app_location_city where cityid = '$cityid'");
		
		//城里的人
		$arrUsers = $DB->fetch_all_assoc("select userid from ".dbprefix."app_user_info where cityid = '$cityid' order by uptime desc limit 16");
		if(is_array($arrUsers)){
			foreach($arrUsers as $item){
				$arrUser[] = aac('user',$DB)->getUserForApp($item['userid']);
			}
		}
		
		//城里的活动
		$arrEvents = $DB->fetch_all_assoc("select eventid from ".dbprefix."app_event where cityid='$cityid' order by addtime desc limit 6");
		
		if(is_array($arrEvents)){
			foreach($arrEvents as $item){
				$arrEvent[] = aac('event',$DB)->getEventByEventid($item['eventid']);
			}
		}
		
		//城里的动态
		
		$title = $strCity['cityname'];
		include TmooTemplate("my");
	}
	
}
